<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE>
<html>
<head>
	<title>新增用户</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<script src="../scripts/boot.js" type="text/javascript"></script>
	<style type="text/css">
	.mini-required .mini-textbox-border{
		background: none !important;
	}
	html,body {
		margin: 0;
		padding: 0;
		border: 0;
	} 
	*{
		font-size:14px;
		font-family:-apple-system-font, "Helvetica Neue", sans-serif;
	}
	</style>

</head>

<body>
<div class="mini-fit">
	<div class="mini-panel" title="header" iconCls="icon-add"
		borderStyle="border:0px" style="width:100%;height:100%;"
		showHeader="false" showToolbar="false" showCloseButton="false"
		showFooter="true">
		
		<div id="form1">
			<table style="margin:0;">
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">用户名<span style="color:#CC0000;">*</span>：</td>
					<td width="200px"><input name="username" class="mini-textbox" style="width:200px;" required="true" requiredErrorText="不能为空"/></td>
				</tr>
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">密码<span style="color:#CC0000;">*</span>：</td>
					<td width="200px"><input name="password" class="mini-password" style="width:200px;" required="true" requiredErrorText="不能为空"/></td>
				</tr>
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">姓名<span style="color:#CC0000;">*</span>：</td>
					<td width="200px"><input name="truename" class="mini-textbox" style="width:200px;" required="true" requiredErrorText="不能为空"/></td>
				</tr>
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">职务：</td>
					<td width="200px"><input name="duty" class="mini-textbox" style="width:200px;"/></td>
				</tr>
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">角色<span style="color:#CC0000;">*</span>：</td>
					<td width="200px">
						<div class="mini-combobox" name="roleIds" style="width:250px;"  popupWidth="400" textField="name" valueField="id"
									   url="roleList" value="" multiSelect="true" showClose="true" oncloseclick="onCloseClick">
							<columns>
								<column header="角色名称" field="text"></column>
							</columns>
						</div>
					</td>
				</tr>
				<tr style="height: 36px;line-height: 36px;">
					<td width="140px" align="right">部门<span style="color:#CC0000;">*</span>：</td>
					<td width="200px">
						<div class="mini-combobox" name="departmentIds" style="width:250px;"  popupWidth="400" popupHeight="150" textField="name" valueField="id"
									   url="departmentList" value="" multiSelect="true" showClose="true" oncloseclick="onCloseClick">
							<columns>
								<column header="部门名称" field="text"></column>
							</columns>
						</div>
					</td>
				</tr>

			</table>
		</div>
	
		<!--footer-->
		<div property="footer" style="text-align:center;padding:5px">
			<a class="mini-button" plain="true" iconCls="icon-ok" onclick="save()">确定</a>
			<a class="mini-button" plain="true" iconCls="icon-remove" onclick="closeWindow()">取消</a>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(function(){
		mini.parse();
	});

	function onCloseClick(e) {
		var obj = e.sender;
		obj.setText("");
		obj.setValue("");
	}
	
	function save() {
		var form = new mini.Form("#form1");
		form.validate();
		if (form.isValid() == false)
			return;
		var data = form.getData();
		mini.mask({
			el: document.body,
			cls: 'mini-mask-loading',
			html: '正在处理，请耐心等待 ...'
		}); 
		$.ajax({
			url : "save",
			type : "post",
			data : data,
			cache : false,
			success : function(text) {
				mini.unmask();
				var result = mini.decode(text);
				if (result.res) {
					closeWindow("save");
				} else {
					mini.alert(result.msg, "提示");
				}
			},
			error : function(jqXHR, textStatus, errorThrown) {
				mini.unmask();
				alert(jqXHR.responseText);
			}
		});
	}
	
	function closeWindow(action) {
		if (window.CloseOwnerWindow)
			return window.CloseOwnerWindow(action);
		else
			window.close();
	}
	function cancel(e) {
		closeWindow(e);
	}
	
</script>
</body>
</html>
</html>

